import React, { Component } from "react";

const Child = (props) => {
  // 默认情况下children是一个数组
  console.log(props.children);
  return (
    <div>
      {props.children.a} - child组件 - {props.children.b}
    </div>
  );
};

class App extends Component {
  render() {
    return (
      <>
        <h3>具名插槽</h3>
        <Child>
          {/* <span>123</span>
          <span>456</span> */}

          {/* 具名插槽推荐传入对象，key就是插槽名字 */}
          {{
            a: <span>123</span>,
            b: <span>456</span>,
          }}
        </Child>
      </>
    );
  }
}

export default App;
